<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span>商品名称</label>
    <div class="col-sm-9 col-xs-12">
        <input type="text" name="goodsname" id="goodsname" class="form-control" value="{$item['title']}" />
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品属性</label>
    <div class="col-sm-9 col-xs-12" >
        <label for="isrecommand" class="checkbox-inline">
            <input type="checkbox" name="isrecommand" value="1" id="isrecommand" {if $item['isrecommand'] == 1}checked="true"{/if} /> 首页推荐
        </label>
        <label for="isnew" class="checkbox-inline">
            <input type="checkbox" name="isnew" value="1" id="isnew" {if $item['isnew'] == 1}checked="true"{/if} /> 新品推荐
        </label>
        <label for="ishot" class="checkbox-inline">
            <input type="checkbox" name="ishot" value="1" id="ishot" {if $item['ishot'] == 1}checked="true"{/if} /> 热卖推荐
        </label>
        <label for="isdiscount" class="checkbox-inline">
            <input type="checkbox" name="isdiscount" value="1" id="isdiscount" {if $item['isdiscount'] == 1}checked="true"{/if} /> 折扣商品
        </label>
        <label for="istime" class="checkbox-inline">
            <input onclick="_istimediv(this);" type="checkbox" name="istime" value="1" id="istime" {if $item['istime'] == 1}checked="true"{/if} /> 限时卖
        </label>
    </div>
</div>
<div class="form-group" id="istimediv"{if $item['istime'] != 1} style="display:none;"{/if}>
    <label class="col-xs-12 col-sm-3 col-md-2 control-label"> </label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group" style="max-width: 500px">
            <span class="input-group-addon">限时时间：</span>
            {php echo tpl_form_field_date('timestart', !empty($item['timestart']) ? date('Y-m-d H:i',$item['timestart']) : date('Y-m-d H:i'), 1)}
            <span class="input-group-addon">-</span>
            {php echo tpl_form_field_date('timeend', !empty($item['timeend']) ? date('Y-m-d H:i',$item['timeend']) : date('Y-m-d H:i'), 1)}
        </div>
    </div>
</div>
<script>
    function _istimediv(obj) {
        if ($(obj).is(':checked')) {
            $("#istimediv").show(200);
        }else{
            $("#istimediv").hide(200);
        }
    }
</script>

<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span>分类</label>
    <div class="col-sm-4 col-xs-6">
        <select class="form-control" style="margin-right:15px;" id="pcate" name="pcate" onchange="fetchChildCategory(this.options[this.selectedIndex].value)"  autocomplete="off">
            <option value="0">请选择一级分类</option>
            {loop $category $row}
            {if $row['parentid'] == 0}
            <option value="{$row['id']}" {if $row['id'] == $item['pcate']} selected="selected"{/if}>{$row['name']}</option>
            {/if}
            {/loop}
        </select>
    </div>
    <div class="col-sm-4 col-xs-6">
        <select class="form-control" id="cate_2" name="ccate" autocomplete="off">
            <option value="0">请选择二级分类</option>
            {if !empty($item['ccate']) && !empty($children[$item['pcate']])}
            {loop $children[$item['pcate']] $row}
            <option value="{$row[0]}" {if $row[0] == $item['ccate']} selected="selected"{/if}>{$row[1]}</option>
            {/loop}
            {/if}
        </select>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品图</label>
    <div class="col-sm-9 col-xs-12">
        {php echo tpl_form_field_image('thumb', $item['thumb'], '', array('extras' => array('text' => 'readonly')))}
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">限时特价首页图</label>
    <div class="col-sm-9 col-xs-12">
        {php echo tpl_form_field_image('xsthumb',$item['xsthumb'])}
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">其他图片</label>
    <div class="col-sm-9 col-xs-12">
        {php echo tpl_form_field_multi_image('thumbs',$piclist)}
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品编号</label>
    <div class="col-sm-4 col-xs-12">
        <input type="text" name="goodssn" id="goodssn" class="form-control" value="{$item['goodssn']}" />
    </div>
</div>
<div class="form-group">
    <label class=" col-sm-3 col-md-2 control-label">商品条码</label>
    <div class="col-sm-4 col-xs-12">
        <input type="text" name="productsn" id="productsn" class="form-control" value="{$item['productsn']}" />
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品价格</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group">
            <span class="input-group-addon">销售价</span>
            <input type="text" name="marketprice" id="marketprice" class="form-control" value="{$item['marketprice']}" />
            <span class="input-group-addon">元</span>
        </div>
        <br>
        <div class="input-group">
            <span class="input-group-addon">市场价</span>
            <input type="text" name="productprice" id="productprice" class="form-control" value="{$item['productprice']}" />
            <span class="input-group-addon">元</span>
        </div>
        <!--<br>
        <div class="input-group">
            <span class="input-group-addon">成本价</span>
            <input type="text" name="costprice" id="costprice" class="form-control" value="{$item['costprice']}" />
            <span class="input-group-addon">元</span>
        </div>-->
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">重量</label>
    <div class="col-sm-6 col-xs-12">
        <div class="input-group">
            <input type="text" name="weight" id="weight" class="form-control" value="{$item['weight']}" />
            <span class="input-group-addon">克</span>
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">库存</label>
    <div class="col-sm-6 col-xs-12">
        <div class="input-group">
            <input type="text" name="total" id="total" class="form-control" value="{$item['total']}" />
            <span class="input-group-addon">件</span>
        </div>
        <span class="help-block">当前商品的库存数量，-1则表示不限制。</span>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">减库存方式</label>
    <div class="col-sm-9 col-xs-12">
        <label for="totalcnf1" class="radio-inline"><input type="radio" name="totalcnf" value="0" id="totalcnf1" {if empty($item) || $item['totalcnf'] == 0}checked="true"{/if} /> 拍下减库存</label>
        &nbsp;&nbsp;&nbsp;
        <label for="totalcnf2" class="radio-inline"><input type="radio" name="totalcnf" value="1" id="totalcnf2"  {if !empty($item) && $item['totalcnf'] == 1}checked="true"{/if} /> 付款减库存</label>
        &nbsp;&nbsp;&nbsp;
        <label for="totalcnf3" class="radio-inline"><input type="radio" name="totalcnf" value="2" id="totalcnf3"  {if !empty($item) && $item['totalcnf'] == 2}checked="true"{/if} /> 永不减库存</label>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">购买积分</label>
    <div class="col-sm-6 col-xs-12">
        <div class="input-group">
            <input type="text" name="credit" id="credit" class="form-control" value="{$item['credit']}" />
            <span class="input-group-addon">分</span>
        </div>
        <p class="help-block">会员购买积分, 如果不填写，则默认为不奖励积分</p>
    </div>
</div>

<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">1级佣金比例</label>
    <div class="col-sm-6 col-xs-12">
        <div class="input-group">
            <input type="text" name="commission" id="commission" class="form-control" value="{$item['commission']}" />
            <span class="input-group-addon">%</span>
        </div>
        <p class="help-block">1级佣金的比例,不填使用系统默认！</p>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">2级佣金比例</label>
    <div class="col-sm-6 col-xs-12">
        <div class="input-group">
            <input type="text" name="commission2" id="commission2" class="form-control" value="{$item['commission2']}" />
            <span class="input-group-addon">%</span>
        </div>
        <p class="help-block">2级佣金的比例,不填使用系统默认！</p>
    </div>
</div>
<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">3级佣金比例</label>
    <div class="col-sm-6 col-xs-12">
        <div class="input-group">
            <input type="text" name="commission3" id="commission3" class="form-control" value="{$item['commission3']}" />
            <span class="input-group-addon">%</span>
        </div>
        <p class="help-block">3级佣金的比例,不填使用系统默认！</p>
    </div>
</div>

<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否上架销售</label>
    <div class="col-sm-6 col-xs-12">
        <label for="isshow1" class="radio-inline"><input type="radio" name="status" value="1" id="isshow1" {if $item['status'] == 1}checked="true"{/if} /> 是</label>
        <label for="isshow2" class="radio-inline"><input type="radio" name="status" value="0" id="isshow2"  {if $item['status'] == 0}checked="true"{/if} /> 否</label>
    </div>
</div>


<script language="javascript">

$(function(){

	var i = 0;
	$('#selectimage').click(function() {
		var editor = KindEditor.editor({
			allowFileManager : false,
			imageSizeLimit : '30MB',
			uploadJson : './index.php?act=attachment&do=upload'
		});
		editor.loadPlugin('multiimage', function() {
			editor.plugin.multiImageDialog({
				clickFn : function(list) {
					if (list && list.length > 0) {
						for (i in list) {
							if (list[i]) {
								html =	'<li class="imgbox" style="list-type:none">'+
								'<a class="item_close" href="javascript:;" onclick="deletepic(this);" title="删除"></a>'+
								'<span class="item_box"> <img src="'+list[i]['url']+'" style="height:80px"></span>'+
								'<input type="hidden" name="attachment-new[]" value="'+list[i]['filename']+'" />'+
								'</li>';
								$('#fileList').append(html);
								i++;
							}
						}
						editor.hideDialog();
					} else {
						alert('请先选择要上传的图片！');
					}
				}
			});
		});
	});
});
function deletepic(obj){
	if (confirm("确认要删除？")) {
		var $thisob=$(obj);
		var $liobj=$thisob.parent();
		var picurl=$liobj.children('input').val();
		$.post('{php echo $this->createMobileUrl('ajaxdelete',array())}',{ pic:picurl},function(m){
			if(m=='1') {
				$liobj.remove();
			} else {
				alert("删除失败");
			}
		},"html");
	}
}

    </script>